﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Transactions;
using MISInterface;

namespace InsideDL.MISData
{
    public class DataAC001 : DataMatrix,iUpload
    {
//        public void Upload(object[] p_para)
//        {            
//            string[] list = p_para[1] as string[];
//            string path = Convert.ToString(p_para[0]);
//            lines = System.IO.File.ReadAllLines(string.Format("{0}\\{1}", path,list[0]) , Encoding.Default);
//            string[] paraNames;
//            paraNames = new[] { "acc_no", "acc_name"};
//            string sql = @"
//INSERT INTO AC001(acc_no,acc_name) VALUES(@acc_no,@acc_name)
//"; 
//            char[] splitMark = new[] { ' ' };
//            DbType[] dbTypes = new[]{DbType.String,DbType.String};
//            check(string.Empty);
//            base.upLoad(sql, paraNames, splitMark, dbTypes); 
//        }

        protected override void check(string p_ym)
        {
            string sql = @"TRUNCATE TABLE AC001_TEMP";
            System.Data.Common.DbCommand cmd = getCommand();
            cmd.CommandText = sql;
            executeSQL(cmd);
        }

        #region iUpload 成員

        public void Upload(object[] p_para)
        {
            string[] list = p_para[1] as string[];
            string path = Convert.ToString(p_para[0]);
            lines = System.IO.File.ReadAllLines(string.Format("{0}\\{1}", path, list[0]), Encoding.Default);
            string[] paraNames;
            paraNames = new[] { "acc_no", "acc_name" };
            string sql = @"
INSERT INTO AC001_TEMP(acc_no,acc_name) VALUES(@acc_no,@acc_name)
";
            char[] splitMark = new[] { ' ' };
            DbType[] dbTypes = new[] { DbType.String, DbType.String };
            check(string.Empty);
            base.upLoad(sql, paraNames, splitMark, dbTypes); 
        }

        #endregion
    }
}
